<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Exercises</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch05lev1sec15.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch06.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch05lev1sec16"></a>
<h3 class="docSection1Title" id="454331-878">Exercises</h3>
<P><table border="0" cellspacing="16" cellpadding="0"><TR valign="top"><td align="right" class="docText" width="50"><a name="ch05qa1q1"></a><B>5.1</b></TD><TD><p class="docText">Implement <tt>setbuf</tt> using <tt>setvbuf</tt>.</p></TD></TR><TR valign="top"><td align="right" class="docText" width="50"><a name="ch05qa1q2"></a><B><a class="docLink" href="app03lev1sec5.html#ch05qa1q2a2">5.2</a></b></td><TD><p class="docText">Type in the program that copies a file using line-at-a-time I/O (<tt>fgets</tt> and <tt>fputs</tt>) from <a class="docLink" href="ch05lev1sec8.html#ch05lev1sec8">Section 5.8</a>, but use a <tt>MAXLINE</tt> of 4. What happens if you copy lines that exceed this length? Explain what is happening.</P></TD></tr><TR valign="top"><TD align="right" class="docText" width="50"><a name="ch05qa1q3"></a><b><a class="docLink" href="app03lev1sec5.html#ch05qa1q3a3">5.3</a></b></TD><TD><p class="docText"><a name="idd1e41390"></a><a name="idd1e41395"></a><a name="idd1e41400"></a><a name="idd1e41405"></a><a name="idd1e41410"></a><a name="idd1e41415"></a>What does a return value of 0 from <tt>printf</tt> mean?</p></td></tr><tr valign="top"><TD align="right" class="docText" width="50"><a name="ch05qa1q4"></a><b><a class="docLink" href="app03lev1sec5.html#ch05qa1q4a4">5.4</a></b></TD><td><p class="docText">The following code works correctly on some machines, but not on others. What could be the problem?</P>

<pre>
    #include    &lt;stdio.h&gt;

    int
    main(void)
    {
        char    c;
        
        while ((c = getchar()) != EOF)
            putchar(c);
}
</pre><br>

</td></tr><tr valign="top"><td align="right" class="docText" width="50"><a name="ch05qa1q5"></a><b><a class="docLink" href="app03lev1sec5.html#ch05qa1q5a5">5.5</a></b></td><td><p class="docText">Why does <tt>tempnam</tt> restrict the <span class="docEmphasis">prefix</span> to five characters?</p></td></tr><tr valign="top"><td align="right" class="docText" width="50"><a name="ch05qa1q6"></a><b><a class="docLink" href="app03lev1sec5.html#ch05qa1q6a6">5.6</a></b></td><td><p class="docText">How would you use the <tt>fsync</tt> function (<a class="docLink" href="ch03lev1sec13.html#ch03lev1sec13">Section 3.13</a>) with a standard I/O stream?</p></TD></TR><tr valign="top"><TD align="right" class="docText" width="50"><a name="ch05qa1q7"></a><B><a class="docLink" href="app03lev1sec5.html#ch05qa1q7a7">5.7</a></b></TD><td><p class="docText">In the programs in <a class="docLink" href="ch01lev1sec6.html#ch01fig07">Figures 1.7</a> and <a class="docLink" href="ch01lev1sec9.html#ch01fig10">1.10</a>, the prompt that is printed does not contain a newline, and we don't call <tt>fflush</tt>. What causes the prompt to be output?</P></TD></TR></table></p>

<UL></ul></TD></TR></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch05lev1sec15.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch06.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--180-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--180-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
